﻿using GN.Pay.TradeChannel.ProtocolPay;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel
{
    /// <summary>
    /// 交易通道扩展
    /// </summary>
    public static class TradeChannelExtensions
    {
        /// <summary>
        /// 是否支持协议支付
        /// </summary>
        /// <param name="channel">通道</param>
        /// <returns></returns>
        public static bool IsProtocolPay(this ITradeChannel channel)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            return channel is IProtocolPay;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="protocolPay"></param>
        /// <returns></returns>
        public static bool TryProtocolPay(this ITradeChannel channel,out IProtocolPay protocolPay)
        {
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }
            protocolPay = channel as IProtocolPay;
            return protocolPay != null;
        }
    }
}
